<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>大英州租车 - 会员认证</title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="/Public/static/js/dayingzhou.js"></script>
<link type="text/css" rel="stylesheet" href="/Public/static/css/lease_a.css"/>
<style type="text/css">
    *{padding: 0px;margin: 0px;font-family: "黑体";}
    input{outline: none;-webkit-appearance:none;}
    img{border: 0px;}
    .clearfix{zoom:1;}
    .clearfix:after{content: "";height: 0;display: block;visibility: hidden;clear: both;}
    .photo{margin-top: 10px;}
    .photo .pLeft{float: left;width: 36%;height: 78px;line-height: 78px;font-size: 14px;color: #494949;}
    .photo .pImg{float: left;width: 32%;text-align: center;}
    .photo .pImg img{width: 60%;}
    .photo .pImg p{font-size: 14px;color: #494949;line-height: 20px;}
    #file{display: none;}
    #idzfile,#idzfile2{display: none;}
    #idffile,#idffile2{display: none;}
</style>

</head>
<body>
    <div class="da_warp">
        <div class="ServiceCharge">诚信经营 - 严格保护每一位客户隐私！</div>
             <input type="hidden" value="<{$memberid}>" id="memberid" name="memberid">
             <div class="photo clearfix">
                <div class="pLeft">身份证正反面</div>
                <div class="pImg upload">
                    <img src="__PUBLIC__/static/img/photo.png" id="img_recz">
                    <p>正面</p>
                    <input type="file" accept="image/*" id="idzfile"/>
                </div>
                <div class="pImg upload">
                    <img src="__PUBLIC__/static/img/photo.png" id="img_recf">
                    <p>反面</p>
                    <input type="file" accept="image/*" id="idffile"/>
                </div>
            </div>
             <div class="photo clearfix">
                <div class="pLeft">驾驶证主副页</div>
                <div class="pImg upload">
                    <img src="__PUBLIC__/static/img/photo.png" id="img_recz2">
                    <p>主页</p>
                    <input type="file" accept="image/*" id="idzfile2"/>
                </div>
                <div class="pImg upload">
                    <img src="__PUBLIC__/static/img/photo.png" id="img_recf2">
                    <p>副页</p>
                    <input type="file" accept="image/*" id="idffile2"/>
                </div>
            </div>
                <div class="BnBox"><a href="javascript:void(0)" class="BnInfo" onclick="memberinfo()">提交</a></div>      
    </div>

</body>
<script type="text/javascript" src="__PUBLIC__/static/js/layer.m/layer.m.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/lrz.all.bundle.js"></script>
<script type="text/javascript">
    $("#img_recz").click(function(){
        $("#idzfile").click();
    });
    $("#img_recf").click(function(){
        $("#idffile").click();
    });
    $("#img_recz2").click(function(){
        $("#idzfile2").click();
    });
    $("#img_recf2").click(function(){
        $("#idffile2").click();
    });

$("#idzfile").change(function(){
    layer.open({
        type: 2,
        content: '上传中...'
    });
    lrz(this.files[0])
    .then(function (rst) {
        // 处理成功会执行
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idzfile';
        up_ajax(rst.base64,type);

    })
    .catch(function (err) {
        // 处理失败会执行
    })
    .always(function () {
        // 不管是成功失败，都会执行
    });
});

$("#idffile").change(function(){
    layer.open({
        type: 2,
        content: '上传中...'
    });
    lrz(this.files[0])
    .then(function (rst) {
        // 处理成功会执行
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idffile';
        up_ajax(rst.base64,type);

    })
    .catch(function (err) {
        // 处理失败会执行
    })
    .always(function () {
        // 不管是成功失败，都会执行
    });
});

$("#idzfile2").change(function(){
    layer.open({
        type: 2,
        content: '上传中...'
    });
    lrz(this.files[0])
    .then(function (rst) {
        // 处理成功会执行
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idzfile2';
        up_ajax(rst.base64,type);

    })
    .catch(function (err) {
        // 处理失败会执行
    })
    .always(function () {
        // 不管是成功失败，都会执行
    });
});

$("#idffile2").change(function(){
    layer.open({
        type: 2,
        content: '上传中...'
    });
    lrz(this.files[0])
    .then(function (rst) {
        // 处理成功会执行
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idffile2';
        up_ajax(rst.base64,type);

    })
    .catch(function (err) {
        // 处理失败会执行
    })
    .always(function () {
        // 不管是成功失败，都会执行
    });
});
function up_ajax(img,type){
    $.ajax({
        url:'<{:U('/home/memberinfo/upload')}>',
        type:'post',
        data:{'img':img},
        async : true, //默认为 true 异步
        error:function(){
           alert_msg('上传失败，请重试！');
        },
        success:function(msg){
            layer.closeAll();
            if(type == 'idzfile'){
                $("#img_recz").attr("src",msg);
            }else if(type == 'idffile'){
                $("#img_recf").attr("src",msg);
            }else if(type == 'idffile2'){
                $("#img_recf2").attr("src",msg);
            }else if(type == 'idzfile2'){
                $("#img_recz2").attr("src",msg);
            }
            
            alert_msg('上传成功，请继续！');
        }
    });
};

function alert_msg(d){
    layer.open({
        content: d,
        time: 2
    });
};

function memberinfo(){
    var memberid = $('#memberid').val();
    var identity_up_url = $('#img_recz').attr('src');
    var identity_side_url = $('#img_recf').attr('src');
    // var identity_hand_url = $('#img_rec').attr('src');
    var driving_main_url = $('#img_recz2').attr('src');
    var driving_side_url = $('#img_recf2').attr('src');
    if(identity_up_url =='/Public/static/img/photo.png'){
        alert_msg("请上传身份证正面");
        return false;
    }
    if(identity_side_url =='/Public/static/img/photo.png'){
        alert_msg("请上传身份证反面");
        return false;
    }
    if(driving_main_url =='/Public/static/img/photo.png'){
        alert_msg("请上传驾驶证主页");
        return false;
    }
    if(driving_side_url =='/Public/static/img/photo.png'){
        alert_msg("请上传驾驶证副页");
        return false;
    }

    $.ajax({
                    url:'<{:U('/home/Memberinfo/getmemberInfo')}>',
                    type:'post',
                    data:{'memberid':memberid,'identity_up_url':identity_up_url,'identity_side_url':identity_side_url,'driving_main_url':driving_main_url,'driving_side_url':driving_side_url},
                    async : true, //默认为true 异步
                    error:function(){
                        alert_msg('提交失败，请重试！');
                        return false;
                    },
                    success:function(msg){
                        alert("提交成功");
                        if(msg == 1){
                          window.location.href = "<{:U('memberinfo/judge_memberinfo')}>";
                        }else{
                          alert("提交失败，请重试！");
                        }
                    }
                   }); 


}
</script>
</html>
